package ru.study.thinkin.chapter11;

import java.util.*;


public class ListIteration {

	public static void main(String[] args) {
		List<Pet> pets = Pets.arrayList(5);
		System.out.println(pets);
		ListIterator<Pet> it = pets.listIterator();		
		
		while(it.hasNext()) {
			System.out.println(it.next()+","+it.nextIndex()+","+it.previousIndex());
		}
		while(it.hasPrevious()) {
			System.out.println(it.previous().id);
		}
		it = pets.listIterator(3);
		while(it.hasNext()) {
			it.next();
			it.set(new Hamster());
		}
		System.out.println(pets);
	}

}
